package item.lxp.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;
import java.util.Date;

//@Component
public class TimeFilter implements Filter {

    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Filter 初始化");
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        long time =  new Date().getTime();
        System.out.println("开始执行filter");
        filterChain.doFilter(request,response);
        System.out.println("执行耗时：" + (new Date().getTime()- time));
    }

    public void destroy() {
        System.out.println("Filter 销毁");
    }
}
